package bod.engine.objs;

import java.awt.image.BufferedImage;

import bod.Images;

public class Player extends Object2D {

	private boolean	left;
	private boolean	right;
	private byte	img;

	public Player(int x, int y) {
		super("Player", x, y, 32, 48);
		this.vertices.add(new Vertex(16, 2));
		this.vertices.add(new Vertex(8, 24));
		this.vertices.add(new Vertex(24, 24));
		this.vertices.add(new Vertex(9, 47));
		this.vertices.add(new Vertex(23, 47));
		this.left = false;
		this.right = false;
		this.img = 0;
	}

	@Override
	public void tick() {
		super.tick();
		if (this.left) {
			this.move(-4, 0);
		}
		if (this.right) {
			this.move(4, 0);
		}
		this.img++;
		if (this.img > 80) {
			this.img = 0;
		}
	}

	public void left(boolean left) {
		this.left = left;
	}

	public void right(boolean right) {
		this.right = right;
	}

	public void jump() {
	}

	@Override
	public BufferedImage getImage() {
		return Images.plyr[this.img / 10];
	}
}